package com.jic.market.impl;

import java.lang.Long;
import java.util.List;

import com.jic.market.entity.PromotionPreGoodsSku;
import com.jic.market.mapper.PromotionPreGoodsSkuMapper;
import com.jic.market.service.PromotionPreGoodsSkuService;
import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.Page;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 预售商品表SKU表
 * @author : 
 * @email : 
 * @since : 2020-03-28 11:30:16
 * @version : v1.0.0
 */
@Service
public class PromotionPreGoodsSkuServiceImpl implements PromotionPreGoodsSkuService{

    @Autowired
    private PromotionPreGoodsSkuMapper promotionPreGoodsSkuMapper;

    @Override
    public long insert(PromotionPreGoodsSku promotionPreGoodsSku) {
        long flag = promotionPreGoodsSkuMapper.insert(promotionPreGoodsSku);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return promotionPreGoodsSkuMapper.delete(id);
    }

    @Override
    public long update(PromotionPreGoodsSku promotionPreGoodsSku) {
        return promotionPreGoodsSkuMapper.update(promotionPreGoodsSku);
    }

    @Override
    public PromotionPreGoodsSku queryByPrimaryKey(Long id){
        return promotionPreGoodsSkuMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<PromotionPreGoodsSku> query(PromotionPreGoodsSku promotionPreGoodsSku){
        return promotionPreGoodsSkuMapper.query(promotionPreGoodsSku);
    }

    @Override
    public PageResult<PromotionPreGoodsSku> queryPage(PromotionPreGoodsSku promotionPreGoodsSku, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<PromotionPreGoodsSku> list = promotionPreGoodsSkuMapper.queryPage(startIndex, pageQuery.getLimit(), promotionPreGoodsSku);
        long count = promotionPreGoodsSkuMapper.queryPageCount(promotionPreGoodsSku);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}